<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    body{
      margin: 0;
      padding: 0;
      background-image: url(./grid.png);
    }
    svg{
      background-color: rgba(255, 0, 0, 0.1);
    }
  </style>
</head>
<body>
  <!-- 在用户坐标系统viewbox绘制的图形，最终会参照视口坐标系viewport来进行等比例缩放 -->
   <!-- c参考：https://www.cainiaojc.com/svg/svg-viewport-view-box.html、https://www.zhangxinxu.com/wordpress/2014/08/svg-viewport-viewbox-preserveaspectratio/ -->
  <svg width="300" height="300" viewbox="0 0 100 50" preserveAspectRatio="xMidYMid meet">
    <rect x="0" y="0" width="100" height="100"></rect>
  </svg>
</body>
</html>